<?php
require_once("Template.php");

class Panel extends Template {
	private $components=array();
	private $bool = true;
	private $blocks = array();
	private $encoding = "UTF-8";

	function __construct($file_str,$root="."){
		parent::__construct($root);
		$this->tfile="file_".rand();
		$this->file_str=$file_str;
		$this->set_file($this->tfile,$this->file_str);
	}

	function add($layout,$component=""){
		if(is_object($component) && $component instanceof Panel)
			$component=$component->getComponent();
		$this->set_var($layout,$component);
	}

	function getComponent($finish=true){
		//if($this->bool==true)$this->add("SID",SID);
		//$this->add("BIO_URL",BIO_URL);
		$h_OUT="out_".rand();
		$this->parse($h_OUT,$this->tfile);
		if($finish){
			return $this->finish($this->get_var($h_OUT));
		}else{
			return $this->get_var($h_OUT);
		}
	}

	function setBlock($block){
		$handler="BLOCK_".rand();
		$this->set_block($this->tfile,$block,$handler);
		$this->blocks[$handler] = $block;
		return $handler;
	}

	function concat($handler){
		$this->parse($handler, $this->blocks[$handler], true);
	}

	/* activa-desactiva al panel a colocar el SID*/
	function setSID($bool=true){
		$this->bool=$bool;
	}


	function show(){
		echo $this->getComponent();
	}
}

?>